package vistas;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Point;
import java.awt.Rectangle;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;

import juego.Records;
import juego.Records.Record;
import programa.Partida;

/*
 * Vista de la pantalla que muestra los puntajes.
 */
@SuppressWarnings("serial")
public class VistaRecords extends JPanel {
	int alto = 700;
	int ancho = 720;

	public VistaRecords() {
		super();

		this.setBackground(Color.black);
		this.setSize(new Dimension(ancho, alto));
		this.setBackground(Color.BLACK);
		this.setLayout(null);
	}

	public VistaRecords(Records records) {
		this();
		int altura = 30;
		int i = 0;
		for (Record record : records.getRecords()) {
			JLabel unRecord = new JLabel();
			unRecord.setBounds(new Rectangle(100, altura, 500, 50));
			unRecord.setForeground(Color.WHITE);
			unRecord.setFont(new Font("Arial", 0, 30));
			unRecord.setText(record.toString());
			this.add(unRecord);
			altura += 50;
			if (++i == 10) {
				break;
			}
		}
		if (i == 0) {
			JLabel ceroRecords = new JLabel("No hay records guardados");
			ceroRecords.setBounds(new Rectangle(100, altura, 500, 50));
			ceroRecords.setForeground(Color.WHITE);
			ceroRecords.setFont(new Font("Arial", 0, 30));
			this.add(ceroRecords);
		}
		JButton salida = new JButton();
		salida.setText("Volver al menu principal");
		salida.setSize(new Dimension(160, 40));
		salida.setLocation(new Point(100, 550));
		salida.setFocusable(false);
		salida.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent e) {
				Partida.getInstance().irAlMenuPrincipal();
			}
		});
		this.add(salida);
	}

}
